package org.red_cross_service.common.wechat;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;

@Component
public class Login {

    @Value("${wechat.pay.v3.miniapp.app-id}")
    private String appId;

    @Value("${wechat.pay.v3.miniapp.app-secret}")
    private String appSecret;

    public String createUrl(String jsCode) {
        String url = "https://api.weixin.qq.com/sns/jscode2session?" +
                "appid={0}&" +
                "secret={1}&" +
                "js_code={2}&" +
                "grant_type=authorization_code";
        return MessageFormat.format(url, appId, appSecret, jsCode);
    }
}
